<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%
    String contextPath1 = request.getContextPath();
%>
<html>
<head>
    <title>Title</title>
    <%@ include file="/common/commonCss.jsp" %>
    <link rel="stylesheet" href="<%=contextPath1%>/css/page.css">
    <link rel="stylesheet" href="<%=contextPath1%>/css/icomoon.min.css">
    <link rel="stylesheet" href="<%=contextPath1%>/extensions/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="<%=contextPath1%>/extensions/bootstrap-table/bootstrap-table.css">
    <link rel="stylesheet" href="<%=contextPath1%>/extensions/bootstrap-table/extensions/edittable/css/edittable.css">

    <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">

    <script src="${ctx}/js/WdatePicker.js"></script>
    <script src="<%=contextPath1%>/extensions/jquery.min.js"></script>
    <%--<script src="<%=contextPath1%>/js/jquery.pager.js"></script>--%>
    <!-- 新引入的jQuery -->
    <script src="<%=contextPath1%>/js/jquery-ui-1.10.3.min.js"></script>
    <script src="<%=contextPath1%>/extensions/bootstrap/js/bootstrap.js"></script>
    <script src="<%=contextPath1%>/extensions/bootstrap-table/bootstrap-table.js"></script>
    <script src="<%=contextPath1%>/extensions/bootstrap-table/extensions/edittable/js/bootstrap-table-editable.js"></script>
    <script src="<%=contextPath1%>/extensions/bootstrap-table/extensions/edittable/js/bootstrap-edittable.js"></script>
    <script src="<%=contextPath1%>/extensions/bootstrap-table/extensions/exporttable/js/bootstrap-table-export.js"></script>
    <script src="<%=contextPath1%>/extensions/bootstrap-table/extensions/exporttable/js/exporttable.js"></script>

    <%--<%@ include file="/common/formValidate.jsp" %>--%>
</head>
<body>
<div class="container">
    <h1>load</h1>
    <p>Load the data to table, the old rows will be removed: <code>$table.bootstrapTable('load', data);</code></p>
    <div id="toolbar">
        <button id="button" class="btn btn-default">load</button>
    </div>
    <table id="table"
           data-toolbar="#toolbar"
           data-height="460">
        <%--<thead>--%>
        <%--<tr>--%>
            <%--<th data-field="id">ID</th>--%>
            <%--<th data-field="name">Item Name</th>--%>
            <%--<th data-field="price">Item Price</th>--%>
        <%--</tr>--%>
        <%--</thead>--%>
    </table>
</div>
<script>
    var $table = $('#table'),
            $button = $('#button');
    $(function () {
        $table.bootstrapTable({
            columns: [
                {field: 'id', title: '订单日期', halign: 'center', align: 'right'},
                {field: 'name', title: '商品TAG', halign: 'center', align: 'right'},
                {field: 'price', title: '商品数量', halign: 'center', align: 'right'},

            ]
        });
        $button.click(function () {
            $table.bootstrapTable('load', randomData());
        });
    });
    function randomData() {
        var startId = ~~(Math.random() * 100),
                rows = [];
        for (var i = 0; i < 10; i++) {
            rows.push({
                id: startId + i,
                name: 'test' + (startId + i),
                price: '$' + (startId + i)
            });
        }
        return rows;
    }
</script>
</body>
</html>
